﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LotteryVote.Logic;
using LotteryVote.Entity;
using LotteryVote.Utility;

namespace LotteryVote.Controls
{
    public partial class TodayCompanyList : System.Web.UI.UserControl
    {
        IList<LotteryCompany> _company;
        IList<LotteryCompany> TodayCompany
        {
            get
            {
                if (_company == null)
                    _company = TodayLotteryCompany.Instance.GetTodayCompany();
                return _company;
            }
        }
        public override string ClientID
        {
            get
            {
                return ddl_company.ClientID;
            }
        }
        public int SelectedValue
        {
            get
            {
                return int.Parse(ddl_company.SelectedValue);
            }
            set
            {
                ddl_company.SelectedValue = value.ToString();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected override void OnInit(EventArgs e)
        {
            if (!IsPostBack)
                BindCompany();
            base.OnInit(e);
        }

        void BindCompany()
        {
            TodayCompany.Insert(0, new LotteryCompany { CompanyId = 0, Name = GetGlobalResourceObject("Resource", "All").ToString() });
            ddl_company.DataSource = TodayCompany;
            ddl_company.DataTextField = LotteryCompany.NAME;
            ddl_company.DataValueField = LotteryCompany.COMPANYID;
            ddl_company.DataBind();
        }
    }
}